{
  "$schema" : "http://json-schema.org/draft/2019-09/schema#",
  "title" : "Payment Card Extract",
  "type" : "object",
  "additionalProperties" : false,
  "properties" : {
    "identifier" : {
      "type" : "integer",
      "description" : "Unique identifier for each file that is produced or processed by CMP"
    },
    "version" : {
      "type" : "number",
      "minimum" : 1.1,
      "maximum" : 1.1,
      "description" : "The current version of the generic extract file. This must match the corresponding inbound file."
    },
    "interfaceCategory" : {
      "type" : "string",
      "enum" : [ "Payments" ],
      "description" : "CMP categorisation of the job associated with this file "
    },
    "interfaceType" : {
      "type" : "string",
      "enum" : [ "Recurring Card Payments" ],
      "description" : "Sub-categorisation of the job"
    },
    "batchDateTime" : {
      "type" : "string",
      "format" : "date-time",
      "description" : "Represents when a batch was created in CMP"
    },
    "extractLoadDateTime" : {
      "type" : "string",
      "format" : "date-time",
      "description" : "Represents when a generic CMP file was created from a batch"
    },
    "recordCount" : {
      "type" : "integer",
      "description" : "Total number of transaction records in the extract file. "
    },
    "extractUpToDate" : {
      "type" : "string",
      "format" : "date-time",
      "description" : "Only payments due on or before this date are included in the extract file. "
    },
    "paymentTotal" : {
      "type" : "number",
      "minimum" : 1.0,
      "maximum" : 9.999999999999998E13,
      "description" : "Total value of payment transactions in the extract file."
    },
    "paymentCount" : {
      "type" : "integer",
      "description" : "Total number of payment transactions in the extract file."
    },
    "refundTotal" : {
      "type" : "number",
      "minimum" : 0.0,
      "maximum" : 9.999999999999998E13,
      "description" : "Total value of refunds transactions in the extract file."
    },
    "refundCount" : {
      "type" : "integer",
      "description" : "Total number of refund transactions in the extract file."
    },
    "details" : {
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/PaymentCardExtractDetail"
      }
    }
  },
  "required" : [ "identifier", "version", "interfaceCategory", "interfaceType", "batchDateTime", "extractLoadDateTime", "recordCount", "extractUpToDate", "paymentTotal", "paymentCount", "refundTotal", "refundCount" ],
  "definitions" : {
    "PaymentCardExtractDetail" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "detailSequence" : {
          "type" : "integer",
          "description" : "Unique identifier of the detail record within the current extract"
        },
        "accountNumber" : {
          "type" : "integer",
          "description" : "Unique identifier of the account in CMP"
        },
        "transactionType" : {
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 1,
          "description" : "Indicates if payment or refund"
        },
        "paymentType" : {
          "type" : "string",
          "maxLength" : 6,
          "description" : "CMP code representing the type of card e.g. VISA, MASTER"
        },
        "amount" : {
          "type" : "number",
          "minimum" : 0.0,
          "maximum" : 9.999999999999E10,
          "description" : "Amount of the payment or refund"
        },
        "transactionNumber" : {
          "type" : "integer",
          "description" : "Unique identifier of the payment/refund transaction.  This should be included in request that are sent to third-party systems"
        },
        "retryCount" : {
          "type" : "integer",
          "description" : "This is greater than zero if a payment transaction is being retried i.e. the transaction follows a soft-decline and temporary suspension"
        },
        "nameOnCard" : {
          "type" : "string",
          "maxLength" : 30,
          "description" : "Card holder name"
        },
        "cardNumber" : {
          "type" : "string",
          "maxLength" : 20,
          "description" : "Card number or portion of number, typically last 4 digits"
        },
        "startDateYymm" : {
          "type" : "string",
          "minLength" : 4,
          "maxLength" : 4,
          "description" : "Year and month that the card is valid from"
        },
        "endDateYymm" : {
          "type" : "string",
          "minLength" : 4,
          "maxLength" : 4,
          "description" : "Year and month that the card is valid until"
        },
        "cardReferenceNumber" : {
          "type" : "string",
          "maxLength" : 100,
          "description" : "Identifier or token that uniquely identifies the credit/debit card on a third party payments system."
        },
        "externalReference" : {
          "type" : "string",
          "maxLength" : 30,
          "description" : "This represents a reference number that can be associated with the payment. This could be supplied by another party in the overall BSS solution"
        },
        "spUniqueIdentifier" : {
          "type" : "string",
          "maxLength" : 100,
          "description" : "This represents a reference number for the payment that has been assigned by the Service Provider"
        },
        "cardType" : {
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 1,
          "description" : "Credit or debit card indicator."
        }
      },
      "required" : [ "detailSequence", "accountNumber", "transactionType", "paymentType", "amount", "transactionNumber", "retryCount", "cardType" ]
    }
  }
}